<?php include _include(ADMIN_PATH.'view/htm/header.inc.htm');?>

<div class="row">
    <div class="col-lg-10 mx-auto">
        <div class="btn-group mb-3" role="group">
            <?php echo admin_tab_active($wechat['setting'], 'index'); ?>
        </div>
        <div class="card">
            <div class="card-body">
                <form action="<?php echo url("plugin-setting-xn_wechat_public"); ?>" method="post" id="form">
                    <h4 class="card-title"><?php echo lang('wechat_setting');?></h4>
                    <div class="form-group row">
                        <label class="col-sm-2 form-control-label">Appkey：</label>
                        <div class="col-sm-10">
                            <?php echo $input['wx_appkey']; ?>
                        </div>
                    </div>
                    <div class="form-group row">
                        <label class="col-sm-2 form-control-label">Appsecret：</label>
                        <div class="col-sm-10">
                            <?php echo $input['wx_appsecret']; ?>
                        </div>
                    </div>
                    <div class="form-group row">
                        <label class="col-sm-2 form-control-label">Token：</label>
                        <div class="col-sm-10">
                            <?php echo $input['wx_token']; ?>
                        </div>
                    </div>
                    <div class="form-group row">
                        <label class="col-sm-2 form-control-label">关注(Focus on)：</label>
                        <div class="col-sm-10">
                            <?php echo $input['follow']; ?>
                        </div>
                    </div>
                    <div class="form-group row">
                        <label class="col-sm-2 form-control-label"></label>
                        <div class="col-sm-10">
                            <button type="submit" class="btn btn-primary btn-block" id="submit"
                                    data-loading-text="<?php echo lang('submiting'); ?>..."><?php echo lang('confirm'); ?></button>
                            <a role="button" class="btn btn-secondary btn-block mt-3"
                               href="javascript:history.back();"><?php echo lang('back'); ?></a>
                        </div>
                    </div>
                </form>
            </div>
            <p class="m-a-1 small">验证地址（Verify the address）：http://<?php echo _SERVER('HTTP_HOST') . '/plugin/xn_wechat_public/route/token.php' ?></p>
            <p class="m-a-1 small">关注回复（Focus on）： username time sitename</p>
            <p class="m-a-1 small">微信公众号申请地址（WeChat public application address)）：<a href="https://mp.weixin.qq.com" target="_blank">https://mp.weixin.qq.com</a></p>
            <p class="m-a-1 small">必须是企业认证服务号!（Must be the enterprise certification service number!）</p>
        </div>
    </div>
</div>

<?php include _include(ADMIN_PATH.'view/htm/footer.inc.htm');?>

<script>

    var jform   = $("#form");
    var jsubmit = $("#submit");
    var referer = '<?php echo http_referer();?>';
    jform.on('submit', function () {
        jform.reset();
        jsubmit.button('loading');
        var postdata = jform.serialize();
        $.xpost(jform.attr('action'), postdata, function (code, message) {
            if ( code == 0 ) {
                $.alert(message);
                jsubmit.text(message).delay(2000).button('reset').location(referer);
                return;
            } else {
                $.alert(message);
                jsubmit.button('reset');
            }
        });
        return false;
    });

</script>